<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/misc/favicon.ico" type="image/x-icon" />
    <title>Single graphics card multi-seat Ubuntu Linux | AMXL</title>
    <link type="text/css" rel="stylesheet" media="all" href="/modules/node/node.css?3" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/poll/poll.css?3" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?3" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?3" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?3" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/user/user.css?3" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/comment/comment.css?3" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/default/files/color/garland-52c34fad/style.css?3" />
<link type="text/css" rel="stylesheet" media="print" href="/themes/garland/print.css?3" />
    <script type="text/javascript" src="/misc/jquery.js?3"></script>
<script type="text/javascript" src="/misc/drupal.js?3"></script>
<script type="text/javascript" src="/misc/tableheader.js?3"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, { "basePath": "/" });
//--><!]]>
</script>
    <!--[if lt IE 7]>
      <link type="text/css" rel="stylesheet" media="all" href="/themes/garland/fix-ie.css" />    <![endif]-->
  </head>
  <body class="sidebar-left">

<!-- Layout -->
  <div id="header-region" class="clear-block"><div id="block-block-2" class="clear-block block block-block">


  <div class="content"><div style="align:center"><script type="text/javascript"><!--
google_ad_client = "pub-4345788974263690";google_ad_slot = "6531667564";google_ad_width = 728; google_ad_height = 90; //--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<a href="javascript:document.cookie='NoGoogleAds=YesPlease; expires=Sun Jan  1 00:00:00 NZDT 2040; path=/';window.location.reload()">No ads please</a>
</div>
</div>
</div>
</div>

    <div id="wrapper">
    <div id="container" class="clear-block">

      <div id="header">
        <div id="logo-floater">
        <h1><a href="/" title="AMXL"><span>AMXL</span></a></h1>        </div>


      </div> <!-- /header -->

              <div id="sidebar-left" class="sidebar">
                    <div id="block-user-1" class="clear-block block block-user">

  <h2>Navigation</h2>

  <div class="content"><ul class="menu"><li class="leaf first last"><a href="/tracker">Recent posts</a></li>
</ul></div>
</div>
        </div>

      <div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
          <div class="breadcrumb"><a href="/">Home</a></div>                              <h2>Single graphics card multi-seat Ubuntu Linux</h2>                                                  <div class="clear-block">
            <div id="node-19" class="node">



      <span class="submitted">Sat, 01/15/2011 - 17:07 — root</span>

  <div class="content clear-block">
    <p>Setting up multi-seat configurations under Ubuntu proved to be quite difficult; here I describe how I did it.</p>
<p><img src="http://www.amxl.com/system/files/Multiseat.jpg" alt="Multi-seat computer configuration" /><br />
Firstly, system information: I'm Ubuntu 10.10, the most recent version, at time of writing of the popular Linux distribution - different distributions may differ slightly. I have an Gigabyte 8400GS PCI Express (PCI-E) card (containing an nVidia 8400 chipset), with one monitor on the DVI (digital) port, and one on the VGA (analogue) port. The motherboard (GeForce6100PM-M2 from Elitegroup / ECS) has onboard graphics, but the BIOS seems to stop the onboard graphics adaptor working when a PCI-E graphics card is added (and no configuration options either on the BIOS that shipped with the motherboard, or after reflashing with the latest version seemed to change that), but using one port on each graphics device worked.</p>
<p>What I was trying to achieve: A multi-seat configuration means having several 'seats' or 'consoles' on set up on the same computer. Each seat has its own screen, keyboard, and mouse, and is used independently by each person. This differs from the (probably more common) multi-head setup, where one user has two screens in front of them.</p>
<p>Secondly, I'm describing how to set it up where both screens share a graphics card. This is the more complicated case, because if you have two seats, each with a different graphics card, you can just run two independent X servers, <a href="https://help.ubuntu.com/community/MultiseatX">as described here</a>. If you have two monitors on the same graphics card, you can't do that directly, because Xorg wants to have exclusive control of a graphics card. Instead, you have to set up one main X server (per card) with two (or more) displays on it, and then use one <a href="http://en.wikipedia.org/wiki/Xephyr">Xephyr</a> instance for each seat. Xephyr is an X server which runs inside another X server; each user has their own Xephyr X server which runs inside the main X server. The main X server has no keyboards or pointers, and instead Xephyr handles them using the <a href="http://en.wikipedia.org/wiki/evdev">evdev</a> framework.</p>
<p>Xephyr is part of the Xorg X server, and Ubuntu comes with Xephyr as a separate package. Unfortunately, however, when building Xephyr, if you want it to support evdev, you need to give it a special configure option, and the version that comes with Ubuntu 10.10 has this turned off. The best solution is to build Xephyr from source. This requires installing some development packages - I had to install the following (but I already had many development packages installed - you might have to install more):</p>
<pre>
sudo apt-get install x11proto-gl-dev x11proto-bigreqs-dev x11proto-composite-dev x11proto-core-dev x11proto-damage-dev x11proto-dmx-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-fonts-dev x11proto-gl-dev x11proto-input-dev x11proto-kb-dev x11proto-print-dev x11proto-randr-dev x11proto-record-dev x11proto-render-dev x11proto-resource-dev x11proto-scrnsaver-dev x11proto-video-dev x11proto-xcmisc-dev x11proto-xext-dev x11proto-xf86bigfont-dev x11proto-xf86dga-dev x11proto-xf86dri-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev x11proto-xf86misc-dev libxkbfile-dev libxfont-dev libpciaccess-dev libglib2.0-dev libudev-dev libselinux-dev libdbus-1-dev libpixman-1-dev libxv-dev
</pre><p>
Download xorg-server from <a href="http://www.x.org/releases/X11R7.6/src/xserver/xorg-server-1.9.3.tar.bz2">here</a>, and configure and build it with:</p>
<pre>
./configure --enable-kdrive --enable-xephyr --enable-xfake --enable-xfbdev --enable-kdrive-kbd --enable-kdrive-mouse --enable-kdrive-evdev --enable-glx-tls
make
make install
</pre><p>
Note that this installs it in /usr/local instead of /usr/, so your system X.org stays installed.</p>
<p>The next step is to get your X server working. It helps to log in remotely to test this. This is somewhat hardware dependent, but it involves editing /etc/X11/xorg.conf or using a configuration tool to get both screens enabled. Follow a multi-head tutorial to get this working. When you have, edit the ServerLayout to comment out all the InputDevice lines. You also want the following in your ServerLayout section, to stop X adding devices automatically:</p>
<pre>
    Option         "AutoEnableDevices" "false"
    Option         "AutoAddDevices"  "false"
    Option         "AllowEmptyInput"       "true"
</pre><p>
Note that if you start X with such a configuration, you won't be able to do anything, as all pointers and mice are disabled, so it is easier to do it from another computer over the network. </p>
<p>Next, you want to set up your Xephyr programs. The gdm version that comes with Ubuntu 10.10 apparently doesn't support multi-seat, and kdm seems to crash when used with Xephyr. So instead, I simply set up a service to start gnome-session on Xephyr for the user expected on each seat (and for security, start a locked screensaver on each seat). This simple approach will only work if there is always the same user on each seat, but is probably good enough for many applications.</p>
<p>I made a shell script in '/usr/bin/start-screens':</p>
<pre>
#!/bin/bash
start-user1-screen >/dev/null&
exec start-user2-screen
</pre><p>
I also made a script, '/usr/bin/startup-X':</p>
<pre>
#!/bin/bash

export XAUTHORITY=/var/run/xauth/0.auth
export DISPLAY=:2.0
if [[ $(ps ax |grep " X " |grep " :0" | wc -l) == 0 ]]; then
  nohup /usr/bin/X vt08 -dpms -s 0 :0 >/dev/null 2>/dev/null &
  xauth -f /var/run/xauth/0.auth generate :0.0 .
fi
</pre><p>
This checks if X is running, and starts it if it isn't. The -dpms to turn off power saving is <b>very</b> important - otherwise your master X screen will lock up after a certain amount of inactivity, because there are no pointers at all on that server, and no amount of moving the mice in Xephyr will restore it. Likewise, the -s 0 to turn off screen blanking. The vt08 just tells it which virtual terminal to run on.</p>
<p>My user scripts look like this (/usr/bin/start-user1-screen):</p>
<pre>
#!/bin/bash

while true; do
/usr/bin/startup-X
export DISPLAY=:0.0
export XAUTHORITY=/var/run/xauth/0.auth
/usr/local/bin/Xephyr :1 -dpms -s 0 -screen 1360x768+0x0 -keybd evdev,,device=/dev/input/by-id/usb-Plus_More_Enterprise_LTD._USB-compliant_keyboard-event-kbd,xkbrules=evdev,xkbmodel=pc105,xkblayout=us -mouse evdev,,device=/dev/input/by-id/usb-15d9_USB_Mouse-event-mouse vt09 -once&
sleep 1
export DISPLAY=:1.0
xauth -f /var/run/xauth/1.auth generate :1.0 .
sudo chown user1.user1 /var/run/xauth/1.auth
export XAUTHORITY=/var/run/xauth/1.auth
su -c  gnome-session user1

sleep 5
done
</pre><p>
Note that the paths to devices in /dev/input/by-id need to be adjusted to match the correct pointer and keyboard for the user's seat, and the screen size needs to be adjusted to match the actual size of the screen. For the other user (/usr/bin/start-user2-screen):</p>
<pre>
#!/bin/bash

sleep 1
while true; do
/usr/bin/startup-X

export DISPLAY=:0.1
export XAUTHORITY=/var/run/xauth/0.auth
/usr/local/bin/Xephyr :2 -dpms -s 0 -screen 1440x900 -keybd evdev,,,device=/dev/input/by-id/usb-0b38_USB-compliant_keyboard-event-kbd,xkbrules=evdev,xkbmodel=pc105,xkblayout=us -mouse evdev,,,device=/dev/input/by-path/platform-i8042-serio-1-event-mouse vt07&
sleep 1
export DISPLAY=:2.0
xauth -f /var/run/xauth/2.auth generate :2.0 .
sudo chown user2.user2 /var/run/xauth/2.auth
export XAUTHORITY=/var/run/xauth/2.auth
su -c gnome-session user2

sleep 5;
done
</pre><p>
Again, the device paths need to be changed, and of course in all of the above you want to change user1 and user2 to the real user names. Note that in the start-user2-screen script, the mouse is a PS2 mouse - and the path is a /dev/input/by-path/platform-i8042* style path - but it could be like the others if it was a USB mouse.</p>
<p>Finally, to make everything launch on system startup, I needed to make an upstart configuration (people on other Linux systems might need an init script instead). In '/etc/init/xlogin.conf':</p>
<pre>
# Sets up X seats

start on (filesystem
          and started dbus
          and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
               or stopped udevtrigger))
stop on runlevel [016]

emits starting-dm

script
    exec /usr/bin/start-screens
end script
</pre><p>
One problem I'm experiencing is that the external USB hub holding one of the mice occasionally loses the connection for a second or less - which is enough to render a session useless, because devices are only added to Xephyr when it starts up, and if they stop being available, they get deleted. The only solution is to patch Xephyr - I'm working on a patch to do this. In the meantime, you will want to make sure you have good USB connections to your input devices, and you only unplug them, even temporarily, if you can live with them not working again for that X session.</p>
<p>Update: I made <a href="https://bugs.freedesktop.org/show_bug.cgi?id=33140">a patch for Xephyr</a> to stop input devices disappearing if they are briefly unplugged. Apply the patch on that bug report to your xorg-server before building it if this is an issue for you.</p>
<table id="attachments" class="sticky-enabled">
 <thead><tr><th>Attachment</th><th>Size</th> </tr></thead>
<tbody>
 <tr class="odd"><td><a href="http://www.amxl.com/system/files/Multiseat.jpg">Multiseat.jpg</a></td><td>10.89 KB</td> </tr>
</tbody>
</table>
  </div>

  <div class="clear-block">
    <div class="meta">
        </div>

          <div class="links"><ul class="links inline"><li class="comment_forbidden first last"><span><a href="/user/login?destination=comment%2Freply%2F19%23comment-form">Login</a> or <a href="/user/register?destination=comment%2Freply%2F19%23comment-form">register</a> to post comments</span></li>
</ul></div>
      </div>

</div>
          </div>
                    <div id="footer"><div id="block-system-0" class="clear-block block block-system">


  <div class="content"><a href="http://drupal.org"><img src="/misc/powered-blue-80x15.png" alt="Powered by Drupal, an open source content management system" title="Powered by Drupal, an open source content management system" width="80" height="15" /></a></div>
</div>
<div id="block-block-1" class="clear-block block block-block">


  <div class="content"><p><a href="/user/login">Log in / Create account</a></p>
</div>
</div>
</div>
      </div></div></div></div> <!-- /.left-corner, /.right-corner, /#squeeze, /#center -->


    </div> <!-- /container -->
  </div>
<!-- /layout -->

    </body>
</html>
